package com.cqq.print.base.service.impl;


import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cqq.print.base.dao.PPriceDao;
import com.cqq.print.base.dao.domain.PPrice;
import com.cqq.print.base.service.bean.PPriceBean;


/**
 * @author generated
 * @date 2015-07-01
 */


@Service(value="pPriceService")
public class PPriceServiceImpl implements com.cqq.print.base.service.PPriceService{

             @Autowired
             private PPriceDao pPriceDao;

			
			public PPriceBean getPPriceBeanByProPlanId(Integer proPlanId) {
				if(proPlanId==null||proPlanId<=0)
					return null;
				PPrice price = pPriceDao.getPPriceBeanByProPlanId(proPlanId);
				PPriceBean bean = new PPriceBean();
				BeanUtils.copyProperties(price, bean);
				return bean;
			}

			
			public List<PPriceBean> queryPPriceBeanByProPlanIds(Integer[] proPlanIds) {
				if(proPlanIds==null||proPlanIds.length<1)
					return null;
				String temp="";
				for (Integer planId : proPlanIds) {
					temp=temp+","+planId;
				}
				temp ="{"+temp.substring(1)+"}";
				List<PPrice> listPrice = pPriceDao.queryPPriceBeanByProPlanIds(temp);
				List<PPriceBean> list = null;
				if(listPrice==null || listPrice.size()<1)
					return null;
				for (PPrice price : listPrice) {
					list = new ArrayList<PPriceBean>();
					PPriceBean bean = new PPriceBean();
					BeanUtils.copyProperties(price, bean);
					list.add(bean);
				}
				return list;
			}

}